/******************************************************************************
*
*               Copyright Mentor Graphics Corporation 2003
*                           All rights reserved
*
*   THIS WORK CONTAINS TRADE SECRETS AND PROPRIETARY INFORMATION WHICH IS
*    THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
*                        SUBJECT TO LICENSE TERMS
*
*******************************************************************************

*******************************************************************************
* FILE NAME                                                          VERSION
* act_array_types_test.c                                               1.1
*
* COMPONENT
* ANSI/ISO C test application
*
* DESCRIPTION
* Demonstrates arithmetic operations on array elements
*
* DATA STRUCTURES
*
*
* FUNCTIONS
* int ansi_c_test(int counter)          Entry point for tests
*
* DEPENDENCIES
* act_test.h
******************************************************************************/

#include "act_test.h"

#if ACT_ARRAY_TYPES_TEST

#define INT_ARRAY_SIZE  10

static volatile int g_array_counter = 0;

int     g_int_array[INT_ARRAY_SIZE];
int*    g_array_pointers[INT_ARRAY_SIZE];


/******************************************************************************
* FUNCTION
* int array_pointer_test( int* intarray )
*
* DESCRIPTION
* Sums the intarray[] i.e. g_int_array[] and assign the total to counter
*
* INPUTS
* int* intarray                         Pointer to array of ints
*
* OUTPUTS
* int counter                           Counter is returned back to caller
******************************************************************************/
int array_pointer_test( int* intarray )
{
     int i;
     int counter=0;
     for (i=0;i < INT_ARRAY_SIZE;i++)
     {
          intarray[i] = intarray[i] + 1;
          counter += intarray[i];
     }

     return counter;
}


/******************************************************************************
* FUNCTION
* int act_array_types_test(int value)
*
* DESCRIPTION
* Fills g_int_array[] with the value of the expression
* g_array_counter +1 and then calls the function array_pointer_test()
*
* INPUTS
* int value                             Pointer to array of ints
*
* OUTPUTS
* int
******************************************************************************/
int act_array_types_test(int value)
{
     int i;
     for (i=0;i < INT_ARRAY_SIZE;i++)
     {
          g_int_array[i] = g_array_counter + i;
          g_array_pointers[i] = &g_int_array[i];
     }

     g_array_counter++;

     return array_pointer_test(g_int_array);
}

#endif
